home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / gfx / show / swfplayersrc.lha / Player / image.c < prev    next >
C/C++ Source or Header  |  2002-11-05  |  4KB  |  151 lines

  1. /*
  2. **
  3. ** $VER: image.c 0.5 (05.11.02)
  4. ** Description
  5. **
  6. ** (C) Copyright 1999 Paul Hill
  7. ** (C) Copyright 2002 Alexandre Balaban
  8. **
  9. ** $HISTORY :
  10. **        - 0.5, 05.11.02 : Added pack pragma directives for PPC compilation
  11. **        - 0.4, 04.11.02 : Corrected PPC includes
  12. **        - 0.3, 03.10.02 : Corrected PPC compilation
  13. **        - 0.2, 27.07.02 : Cleanup
  14. **        - 0.1, 27.02.99 : Original version by Paul Hill
  15. **
  16. */
  17.  
  18. #pragma pack(2)
  19.  
  20. #ifdef __PPC__
  21. #include </ADE/os-includeppc/proto/graphics.h>
  22. #include </ADE/os-includeppc/proto/intuition.h>
  23. #include </ADE/os-includeppc/proto/cybergraphics.h>
  24. #else
  25. #include <proto/graphics.h>
  26. #include <proto/intuition.h>
  27. #include <clib/cybergraphics_protos.h>
  28. #endif // __PPC__
  29.  
  30. #include <cybergraphx/cybergraphics.h>
  31.  
  32. #pragma pack()
  33.  
  34. #include <stdio.h>
  35. #include "swfplayer.h"
  36.  
  37. extern struct Library *CyberGfxBase;
  38. #ifdef DITHER_CODE
  39. char *dith_dither(int w, int h, long *t, unsigned long *i);
  40. void dith_setup(int dim, int nr, int ng, int nb, unsigned long *ptab,int w,int h);
  41.  
  42. static int do_dither=0;
  43. static int dit=0;
  44. unsigned long ptab[256];
  45. #endif
  46.  
  47. void drawchunkypixels(UBYTE *canvasBuffer,LONG bpp,LONG bpl)
  48. {
  49.   #ifdef FULLSCREEN_CODE
  50.     if (swfinfo.fullscreen)
  51.     {
  52.     // TODO: fullscreen drawing
  53.     }
  54.     else
  55.   #endif
  56.     {
  57.  
  58.     #ifdef DITHER_CODE
  59.     if (do_dither)
  60.     {
  61.         if (!dit)
  62.         {
  63.             dith_setup(2,4,4,4, ptab,swfinfo.width,swfinfo.height);
  64.             dit = 1;
  65.         }
  66.         bpp=1;
  67.     }
  68.     #endif
  69.  
  70.         switch (bpp)
  71.         {
  72.             case 1:                                                                // 8bits per pixel
  73.                 if (CyberGfxBase)
  74.                 {
  75.                     WritePixelArray(    (APTR) canvasBuffer,                // OK!
  76.                                                   0,
  77.                                                   0,
  78.                                                   swfinfo.width,
  79.                                                   swfinfo.rport,
  80.                                                   swfinfo.winborderleft,
  81.                                                   swfinfo.winbordertop,
  82.                                                   swfinfo.width,
  83.                                                   swfinfo.height,
  84.                                                   RECTFMT_LUT8);
  85.                 } else
  86.                 {
  87.                     if (swfinfo.kick31)
  88.                     {
  89.                         WriteChunkyPixels(swfinfo.rport,                    // OK!
  90.                                                       swfinfo.winborderleft,
  91.                                                       swfinfo.winbordertop,
  92.                                                       swfinfo.width + swfinfo.winborderleft - 1,
  93.                                                       swfinfo.height + swfinfo.winbordertop - 1,
  94.                                                       (UBYTE *) canvasBuffer,
  95.                                                       swfinfo.width);
  96.                     }
  97.                     else
  98.                     {
  99.                         /* THIS IS WRONG!!!!! */
  100.                         WritePixelArray8(    swfinfo.rport,
  101.                                                       swfinfo.winborderleft,
  102.                                                       swfinfo.winbordertop,
  103.                                                       swfinfo.width + swfinfo.winborderleft - 1,
  104.                                                       swfinfo.height + swfinfo.winbordertop - 1,
  105.                                                       (UBYTE *) canvasBuffer,
  106.                                                       swfinfo.tmprport);
  107.                     }
  108.                 }
  109.                 break;
  110.  
  111.             case 2:                                                                // 15 / 16bit
  112.                 /* CyberGraphic's WritePixelArray()
  113.                     doesn't support 15/16bit */
  114.                 break;
  115.  
  116.             case 3:                                                                // 24 bit RGB format
  117.                 /* Flash doesn't support 3bytes/pixel yet.
  118.                     I'll probably add it myself later. */
  119. #ifdef NOT_YET
  120.                 WritePixelArray(    (APTR) canvasBuffer,
  121.                                               0,
  122.                                               0,
  123.                                               bpl,
  124.                                               swfinfo.rport,
  125.                                               swfinfo.winborderleft,
  126.                                               swfinfo.winbordertop,
  127.                                               swfinfo.width,
  128.                                               swfinfo.height,
  129.                                               RECTFMT_RGB);
  130. #endif
  131.                 break;
  132.  
  133.             case 4:                                                                // 32 bit ARGB format
  134.                 if (CyberGfxBase)
  135.                 {
  136.                     WritePixelArray(    (APTR) canvasBuffer,
  137.                                                   0,
  138.                                                   0,
  139.                                                   bpl,
  140.                                                   swfinfo.rport,
  141.                                                   swfinfo.winborderleft,
  142.                                                   swfinfo.winbordertop,
  143.                                                   swfinfo.width,
  144.                                                   swfinfo.height,
  145.                                                   RECTFMT_ARGB);
  146.                 }
  147.                 break;
  148.         }
  149.     }
  150. }
  151.